package bieche.eric.util;

import java.io.Serializable;

public class TribbleRound implements Serializable
{
   
   /**
    * 
    */
   private static final long serialVersionUID = -1227515759096794184L;

   public static final int MAXROUNDS = 5;
   public static final String[] POINTTYPES = { "Winner", "Poison", "Toxin", "Antidote", "Score", "Bonus", "Copy", "Quadruple", "Tally" };

   public static final int WINNER = 1;
   public static final int POISON = 2;
   public static final int TOXIN = 3;
   public static final int ANTIDOTE = 4;
   public static final int SCORE = 5;
   public static final int BONUS = 6;
   public static final int COPY = 7;
   public static final int QUADRUPLE = 8;
   public static final int TALLY = 9;

   private int winnerPoints;
   private int bonusPoints;
   private int poisonPoints;
   private int toxinPoints;
   private int copyPoints;
   private int scorePoints;
   private int quadruplePoints;
   private int antidotePoints;
   private int tallyPoints;

   public TribbleRound()
   {
      winnerPoints = 0;
      bonusPoints = 0;
      poisonPoints = 0;
      toxinPoints = 0;
      copyPoints = 0;
      scorePoints = 0;
      quadruplePoints = 0;
      antidotePoints = 0;
      tallyPoints = 0;
   }

   public int getTallyPoints()
   {
      return this.tallyPoints;
   }

   public int getWinnerPoints()
   {
      return this.winnerPoints;
   }

   public int getBonusPoints()
   {
      return this.bonusPoints;
   }

   public int getPoisonPoints()
   {
      return this.poisonPoints;
   }

   public int getToxinPoints()
   {
      return this.toxinPoints;
   }

   public int getCopyPoints()
   {
      return this.copyPoints;
   }

   public int getScorePoints()
   {
      return this.scorePoints;
   }

   public int getQuadruplePoints()
   {
      return this.quadruplePoints;
   }

   public int getAntidotePoints()
   {
      return this.antidotePoints;
   }

   public int getTotalScore()
   {
      return winnerPoints + bonusPoints + poisonPoints + toxinPoints + copyPoints + scorePoints + quadruplePoints + antidotePoints + tallyPoints;
   }

   public void scorePoints(int type, int amount)
   {
      switch( type )
      {
         case TribbleRound.WINNER:
            this.winnerPoints += amount;
            break;
         case TribbleRound.BONUS:
            this.bonusPoints += amount;
            break;
         case TribbleRound.POISON:
            this.poisonPoints += amount;
            break;
         case TribbleRound.TOXIN:
            this.toxinPoints += amount;
            break;
         case TribbleRound.COPY:
            this.copyPoints += amount;
            break;
         case TribbleRound.SCORE:
            this.scorePoints += amount;
            break;
         case TribbleRound.QUADRUPLE:
            this.quadruplePoints += amount;
            break;
         case TribbleRound.ANTIDOTE:
            this.antidotePoints += amount;
            break;
         case TribbleRound.TALLY:
            this.tallyPoints += amount;
            break;
         default:
            break;
      }
   }// End of scorePoints

   public String getToStringForToolTip()
   {
      return this.toString().replaceAll( "\n", "<br\\>");
   }

   @Override public String toString()
   {
      return String.format("%-10s %7d\n", "Bonus", this.bonusPoints)
            + String.format("%-10s %7d\n", "Poison", this.poisonPoints)
            + String.format("%-10s %7d\n", "Toxin", this.toxinPoints)
            + String.format("%-10s %7d\n", "Copy", this.copyPoints)
            + String.format("%-10s %7d\n", "Antidote", this.antidotePoints)
            + String.format("%-10s %7d\n", "Score", this.scorePoints)
            + String.format("%-10s %7d\n", "Quadruple", this.quadruplePoints)
            + String.format("%-10s %7d\n", "Tally", this.tallyPoints)
            + String.format("%-10s %7d\n", "Winner", this.winnerPoints);
   }

   public String getHeaders()
   {
      StringBuffer sb = new StringBuffer(512);
      for( String s : TribbleRound.POINTTYPES )
      {
         sb.append(String.format("%10s", s));
      }
      sb.append(String.format("\n"));

      return sb.toString();
   }

}// End of Class
